clear; clc;
load('data/recsys/movielen100k.mat');

para.tau = 1.01;
para.maxTime = 3600;

[row, col, val] = find(data);
idx = randperm(length(val));

traIdx = idx(1:floor(length(val)*0.5));

clear idx;

traData = sparse(row(traIdx), col(traIdx), val(traIdx));
traData(size(data,1), size(data,2)) = 0;

%% start testing
close all;
para.tol = 1e-1;
para.speedup = 1;
para.maxIter = 5000;

for i = 1:3
    
para.regType = i;
para.maxR = 15;

switch(i)
    case 1
        lambda = 20;
        theta1 = lambda*2;
    case 2
        lambda = 1000;
        theta1 = sqrt(lambda);
    case 3
        lambda = 20;
        theta1 = 1;
end

[~, ~, ~, out] = FastMatCompCheck( traData, lambda, theta1, para );

figure;
semilogy(out.objcheck, ':', 'linewidth',2);
hold on;
semilogy(out.objdiff, '--', 'linewidth',2);
legend('Check Criterion', 'Function Decrease');
xlabel('Iterations');
ylabel('Value in Logarithm');

end

clear data i val valIdx tstIdx traIdx col row traData movies Age;
save('movielen100k-3');


